Ext.define('TS.view.inv.InventoryAddProduct', {
    extend: 'Ext.window.Window',
    alias : 'widget.inventoryaddproduct',

    title : '添加商品',
    //layout: 'fit',
	config: {
		parentCt:''
    },
    initComponent: function() {
        this.items = [
            {
    			xtype: 'form',
    			collapsible :true,
                defaultType:'fieldcontainer',
			    defaults:{
						layout: {
							type:'hbox',//横排布局
							align:'stretch'
						},
						fieldDefaults:{
							readOnly:true,  
							labelAlign:'left'
				    	},
				    	defaultType:'textfield'
				    	
				},
				items:[
					{
						items:[
							{
		                        name : 'productCode',
		                        fieldLabel: '商品编号',
		                        readOnly:false,
		                        xtype: 'triggerfield',
				    	    	emptyText:'请输入商品编码或名称',
				    	    	trigger1Cls:Ext.baseCSSPrefix + "form-search-trigger",
				    	    	onTriggerClick:function(e){
				    	    		e.keyCode=e.ENTER;//设置为Enter事件
				    	    		this.fireEvent('specialkey',this,e);//点客户查询图标执行搜索
				    	    	}
		                    },
		                    {
		                    	name : 'packSpec',
		                        fieldLabel: '规格'
		                    }
						]
					},
					{
						items:[
							{
		                    	name : 'productName',
		                        fieldLabel: '商品名称',
		                        allowBlank:false,
		                        width:465
		                    }
						]
					},
					{
						items:[
							{
		                    	name : 'manuf',
		                        fieldLabel: '生产企业'
		                    },
		                    {
		                    	name : 'unit',
		                        fieldLabel: '单位'
		                    }
						]
					}
				]
    		},
    		{
    			xtype: 'form',
    			defaultType:'fieldcontainer',
			    defaults:{
						layout: {
							type:'hbox',//横排布局
							align:'stretch'
						}
				},
				items:[{
	                items: [
	                    {
	                        name : 'batchNo',
	                        fieldLabel: '批号',
	                        allowBlank:false,
	                        blankText:'批号不能为空',
	                        xtype: 'triggerfield',
			    	    	trigger1Cls:Ext.baseCSSPrefix + "form-search-trigger",
			    	    	onTriggerClick:function(e){
			    	    		e.keyCode=e.ENTER;//设置为Enter事件
			    	    		this.fireEvent('specialkey',this,e);//点客户查询图标执行搜索
			    	    	}
	                   },
	                   {
							xtype: 'hiddenfield',
	                        name : 'id',
	                        fieldLabel: '批号内码'
	                   },
	                   {
	                   		xtype:'combobox',
							listConfig:{
								emptyText:'没有对应货位',
								maxHeight:200
							},
							fieldLabel:'货位',
							name:'invAddId',
							queryMode:'local',
							store:'base.InvAddsStore',
							valueField:"id",
							displayField :'inventoryAddName',
							forceSelection:true,
							typeAhead : true
							
	                   }
	                ]
				}]
    		}
        ];

        this.buttons = [
            {
                text: '保存',
                action: 'save'
            },
            {
                text: '取消',
                scope: this,
                handler: this.close
            }
        ];

        this.callParent(arguments);
    },
    listeners: {
		afterrender:function(){
			var cbx=this.down('combobox');
			cbx.store.load({
				scope: this,
			    callback: function(records, operation, success) {
			        var id=records[0].get('id');
					cbx.setValue(id);
			    }
			})
			
		}
	}
});